// ** Third Party Components
import axios from 'axios'
import { FileText } from 'react-feather'
import { UncontrolledTooltip } from 'reactstrap'

export let data

// ** Get initial Data
data = [
  {
    id: '100',
    name: '2-4x1',
    IO: '400001',
    status: {
      value: 1,
      label: '正常',
    },
    type: 'Int16',
    equipName: 'BOX007(192.168.1.100)',
    onlineData: '41.770',
    unit: 'kg',
    method: '变化存储',
    security: '-',
    auth: '读',
  },
  {
    id: '101',
    name: '2-4x2',
    IO: '400002',
    status: {
      value: 1,
      label: '正常',
    },
    type: 'Int32',
    equipName: 'BOX007(192.168.1.100)',
    onlineData: '0.28',
    unit: 'm/min',
    method: '变化存储',
    security: '-',
    auth: '读',
  },
  {
    id: '102',
    name: '2-4x3',
    IO: '400003',
    status: {
      value: 1,
      label: '正常',
    },
    type: 'Int32',
    equipName: 'BOX008(192.168.1.100)',
    onlineData: '46.893',
    unit: 'r/min',
    method: '变化存储',
    security: '-',
    auth: '读',
  },
  {
    id: '103',
    name: '2-4x4',
    IO: '400004',
    status: {
      value: 1,
      label: '正常',
    },
    type: 'Int32',
    equipName: 'BOX008(192.168.1.100)',
    onlineData: '53.0',
    unit: 'RPM',
    method: '变化存储',
    security: '-',
    auth: '读写',
  },
]

const statusEnum = {
  0: '#ea5455',
  1: '#56affd',
}
// ** Table Common Column
export const columns = [
  {
    name: '变量ID',
    minWidth: '100px',
    cell: (row) => row.id,
  },
  {
    name: '变量名',
    minWidth: '150px',
    selector: (row) => row.name,
  },
  {
    name: 'IO连接',
    minWidth: '150px',
    selector: (row) => row.IO,
  },
  {
    name: '变量类型',
    minWidth: '150px',
    selector: (row) => row.type,
  },
  {
    name: '设备名称',
    minWidth: '150px',
    selector: (row) => row.equipName,
  },
  {
    name: '状态',
    minWidth: '150px',
    cell: (row) => (
      <span
        style={{
          color: statusEnum[row.status.value],
          border: `1px solid ${statusEnum[row.status.value]}`,
          borderRadius: '4px',
          padding: '1px 4px',
        }}
      >
        {row.status.label}
      </span>
    ),
  },
  {
    name: '实时值',
    minWidth: '150px',
    selector: (row) => row.onlineData,
  },
  {
    name: '单位',
    minWidth: '150px',
    selector: (row) => row.unit,
  },
  {
    name: '存储方式',
    minWidth: '150px',
    selector: (row) => row.method,
  },
  {
    name: '安全类别',
    minWidth: '150px',
    selector: (row) => row.security,
  },
  {
    name: '读写权限',
    minWidth: '150px',
    selector: (row) => row.auth,
  },
]
